﻿using System.Collections.Generic;
using ConsoleAppFramework.Rmq;

namespace ConsoleApp.Rmq
{
    /// <summary>
    /// 长连接，循环取消息
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class ConsumerWorkerBase<T> : RmqComsumerWorkerBase<T>
    {
        protected ConsumerWorkerBase()
        {
            this.RmqUrl = RmqUrlEnum.XiGuaWx;
            FailEnqueue = true;
            NeedLog = false;
        }
        protected abstract override bool HandleComingMessage(T messageDTO);
    }

    /// <summary>
    /// 批量取消息
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class BatchConsumerWorkerBase<T> : RmqBatchComsumerWorkBase<T>
    {
        protected BatchConsumerWorkerBase()
        {
            this.RmqUrl = RmqUrlEnum.XiGuaWx;
        }
        protected abstract override bool HandleComingMessage(List<T> messageDTO);

    }

    /// <summary>
    /// 一次取一条消息，取完就断开连接。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class OneConsumerWorkerBase<T> : RmqOneMsgComsumerWorkerBase<T>
    {
        protected OneConsumerWorkerBase()
        {
            this.RmqUrl = RmqUrlEnum.XiGuaWx;
            FailEnqueue = true;
        }

        protected abstract override bool HandleComingMessage(T messageDTO);
    }
}
